package lightswitch.code.connection;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;

import javax.swing.JOptionPane;

public class ConnectionHelper {
    public static int port = 12345;
    
    public void startListening(){
        try {
            ServerSocket ss = new ServerSocket(port);
            do{
                Socket socket = ss.accept();
                new ClientThread(socket).start();
            } while(true);
        } catch (IOException ex) {
            // TODO Auto-generated catch block
            ex.printStackTrace();
            JOptionPane.showMessageDialog(null, "Cannot listen connection\nCheck application port & start program later", "Message", 1);
            System.exit(1);
        } 
    }
}
